﻿using System;
using System.Runtime.Serialization;

namespace YUIAspNet.Common
{
    /// <summary>
    /// Indicates that the control does not support themes.
    /// </summary>
    [Serializable]
    public class ThemesUnsupportedException : Exception
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ThemesUnsupportedException"/> class.
        /// </summary>
        public ThemesUnsupportedException() : base("This Control does not support themes!")
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ThemesUnsupportedException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="innerEx">The inner ex.</param>
        public ThemesUnsupportedException(String message, Exception innerEx) : base(message, innerEx)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ThemesUnsupportedException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        public ThemesUnsupportedException(string message)
            : base(message)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ThemesUnsupportedException"/> class.
        /// </summary>
        /// <param name="info">The info.</param>
        /// <param name="ctx">The CTX.</param>
        protected ThemesUnsupportedException(SerializationInfo info, StreamingContext ctx) : base(info, ctx)
        {
        }
    }

    /// <summary>
    /// Indicated that the control does not support a specufic theme.
    /// </summary>
    [Serializable]
    public class ThemeNotFoundException : Exception
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ThemeNotFoundException"/> class.
        /// </summary>
        public ThemeNotFoundException()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ThemeNotFoundException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        public ThemeNotFoundException(string message) : base(message)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ThemeNotFoundException"/> class.
        /// </summary>
        /// <param name="themeName">Name of the theme.</param>
        /// <param name="controlName">Name of the control.</param>
        public ThemeNotFoundException(string themeName, string controlName)
            : base("The theme" + themeName + " is not supported in the " + controlName + " control!")
        { }

        /// <summary>
        /// Initializes a new instance of the <see cref="ThemeNotFoundException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="innerEx">The inner ex.</param>
        public ThemeNotFoundException(String message, Exception innerEx)
            : base(message, innerEx)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ThemesUnsupportedException"/> class.
        /// </summary>
        /// <param name="info">The info.</param>
        /// <param name="ctx">The CTX.</param>
        protected ThemeNotFoundException(SerializationInfo info, StreamingContext ctx)
            : base(info, ctx)
        {
        }
    }

    /// <summary>
    /// Raised when trying to serialize property that's required but is not assigned.
    /// </summary>
    [Serializable]
    public class RequiredPropertyException : Exception
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="RequiredPropertyException"/> class.
        /// </summary>
        public RequiredPropertyException()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="RequiredPropertyException"/> class.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        public RequiredPropertyException(string propertyName)
            : base("Property/ies " + propertyName + " is required!")
        { }

        /// <summary>
        /// Initializes a new instance of the <see cref="RequiredPropertyException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="innerEx">The inner ex.</param>
        public RequiredPropertyException(String message, Exception innerEx)
            : base(message, innerEx)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="RequiredPropertyException"/> class.
        /// </summary>
        /// <param name="info">The info.</param>
        /// <param name="ctx">The CTX.</param>
        protected RequiredPropertyException(SerializationInfo info, StreamingContext ctx)
            : base(info, ctx)
        {
        }
    }
}
